package com.jiyun.service.impl;

import com.alibaba.csp.sentinel.util.StringUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiyun.login.pojo.finance.Payable;
import com.jiyun.login.pojo.finance.PayableVo;
import com.jiyun.mapper.PayableMapper;
import com.jiyun.result.Result;
import com.jiyun.service.IPayableService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2025-02-17
 */
@Service
public class PayableServiceImpl extends ServiceImpl<PayableMapper, Payable> implements IPayableService {

    @Autowired
    private PayableMapper payableMapper;

    @Override
    public Result gitAll(PayableVo payableVo) {
        Page<Payable> payablePage = new Page<>(payableVo.getPages(), payableVo.getSize());
        QueryWrapper<Payable> payableQueryWrapper = new QueryWrapper<>();
        if (!StringUtil.isEmpty(payableVo.getSettlementStatus())){
            payableQueryWrapper.eq("settlement_status",payableVo.getSettlementStatus());
        }
        if (!StringUtil.isEmpty(payableVo.getFormer())&&!StringUtil.isEmpty(payableVo.getHoo())){
            payableQueryWrapper.between("creation_time",payableVo.getFormer(),payableVo.getHoo());
        }
        Page<Payable> page = payableMapper.selectPage(payablePage, payableQueryWrapper);
        return Result.ok(page);
    }


}
